//
//  HTClassPurchaseHeadView.swift
//  QuitSmokingApp
//  
//  Created by wealon on 2024.
//  QuitSmokingApp.
//  Helvetica Neue

    

import UIKit

class HTClassPurchaseHeadView: UIView {
    lazy var var_topImageView: UIImageView = {
        let var_imageView = UIImageView()
        var_imageView.image = UIImage(named: "icon_premium_bg_01")
        return var_imageView
    }()
    lazy var var_titleLabel: UILabel = {
        let var_label = UILabel()
        var_label.textColor = .white
        var_label.text = "No premium information"
        var_label.font = UIFont(name: "HelveticaNeue-CondensedBlack", size: 22)
        var_label.ht_strokeText(UIColor("#212329"), strokeWidth: -5.0)
        return var_label
    }()
    
    var isSubscribe = false {
        didSet {
            if isSubscribe {
                ht_layout2()
            } else {
                ht_layout1()
            }
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.addSubview(var_topImageView)
        self.addSubview(var_titleLabel)
        ht_layout1()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
  
    func ht_layout1() {
        var_titleLabel.text = "No premium information"
        let var_image = UIImage(named: "icon_premium_bg_01")!
        var_topImageView.image = var_image
        
        let var_size = var_image.size
        let var_height = var_size.height/var_size.width * (HTClassTool.STATIC_screenWidth - 14.auto()*2)
        
        var_topImageView.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.centerX.equalToSuperview()
            make.width.equalTo(HTClassTool.STATIC_screenWidth - 14.auto()*2)
            make.height.equalTo(var_height)
        }
        var_titleLabel.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
//            make.top.equalToSuperview().offset(19)
            make.centerY.equalTo(var_topImageView.snp.centerY).offset(-10.auto())
            make.height.equalTo(22.auto())
        }
        self.frame = CGRect(x: 0, y: 0, width: HTClassTool.STATIC_safeAreaWidth, height: var_height + 30.auto())
    }
    
    func ht_layout2() {
        var_titleLabel.text = ""
        
        let var_image = UIImage(named: "icon_premium_bg_02")!
        let var_size = var_image.size
        let var_height = var_size.height/var_size.width * (HTClassTool.STATIC_screenWidth - 14.auto()*2)
        
        var_topImageView.image = var_image
        var_topImageView.snp.remakeConstraints { make in
            make.top.equalToSuperview()
            make.centerX.equalToSuperview()
            make.width.equalTo(HTClassTool.STATIC_screenWidth - 14.auto()*2)
            make.height.equalTo(var_height)
        }
        var_titleLabel.snp.remakeConstraints { make in
            make.centerX.equalToSuperview()
            make.bottom.equalTo(var_topImageView.snp.bottom).offset(-20.auto())
            make.height.equalTo(22.auto())
        }
        self.frame = CGRect(x: 0, y: 0, width: HTClassTool.STATIC_safeAreaWidth, height: var_height + 30.auto())
    }
}
